package gui.admin.mtm;

import database.TableDatabaseUsage;
import info.Passenger;

import javax.swing.table.AbstractTableModel;
import java.util.List;

public class PTM extends AbstractTableModel {
    private String[] columnNames={"身份证号","密码","姓名","电话"};
    private List<Passenger> passengerList = TableDatabaseUsage.getInstance().getPassengerInforList();
    private static PTM instance=new PTM();
    public static PTM getInstance(){return instance;}
    @Override
    public int getRowCount() {
        return passengerList.size();
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Passenger dataInfo=passengerList.get(rowIndex);
        if(columnIndex==0){
            return dataInfo.getIdno();
        } else if (columnIndex==1) {
            return dataInfo.getPwd();
        }else if (columnIndex==2){
            return dataInfo.getpName();
        }else if(columnIndex == 3) {
            return dataInfo.getTelephone();
        }
        return null;
    }

    public String getColumnName(int column) {
        return columnNames[column];
    }

    public List<Passenger> getPassengerList() {
        return passengerList;
    }
}
